/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.sisportaria.bean;

import br.com.sisportaria.bean.Pessoa;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author lac
 */
@Entity
@Table(name = "PESSOA_TIPO")
@NamedQueries({@NamedQuery(name = "PessoaTipo.findAll", query = "SELECT p FROM PessoaTipo p Order By p.tpncodg"), @NamedQuery(name = "PessoaTipo.findByPtncodg", query = "SELECT p FROM PessoaTipo p WHERE p.ptncodg = :ptncodg Order By p.tpncodg"), @NamedQuery(name = "PessoaTipo.findByTpncodg", query = "SELECT p FROM PessoaTipo p WHERE p.tpncodg = :tpncodg Order By p.tpncodg")})
public class PessoaTipo implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "PTNCODG")
    private Integer ptncodg;
    @Column(name = "TPNCODG")
    private Integer tpncodg;
    @JoinColumn(name = "PSNCODG", referencedColumnName = "PSNCODG")
    @ManyToOne
    private Pessoa psncodg;

    public PessoaTipo() {
    }

    public PessoaTipo(Integer ptncodg) {
        this.ptncodg = ptncodg;
    }

    public Integer getPtncodg() {
        return ptncodg;
    }

    public void setPtncodg(Integer ptncodg) {
        Integer oldPtncodg = this.ptncodg;
        this.ptncodg = ptncodg;
        changeSupport.firePropertyChange("ptncodg", oldPtncodg, ptncodg);
    }

    public Integer getTpncodg() {
        return tpncodg;
    }

    public void setTpncodg(Integer tpncodg) {
        Integer oldTpncodg = this.tpncodg;
        this.tpncodg = tpncodg;
        changeSupport.firePropertyChange("tpncodg", oldTpncodg, tpncodg);
    }

    public Pessoa getPsncodg() {
        return psncodg;
    }

    public void setPsncodg(Pessoa psncodg) {
        Pessoa oldPsncodg = this.psncodg;
        this.psncodg = psncodg;
        changeSupport.firePropertyChange("psncodg", oldPsncodg, psncodg);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ptncodg != null ? ptncodg.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PessoaTipo)) {
            return false;
        }
        PessoaTipo other = (PessoaTipo) object;
        if ((this.ptncodg == null && other.ptncodg != null) || (this.ptncodg != null && !this.ptncodg.equals(other.ptncodg))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.sisportaria.view.PessoaTipo[ptncodg=" + ptncodg + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
